package com.reform.controller.common;


import com.reform.res.Result;
import com.reform.service.INavService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author mortale
 * @since 2021-06-27
 */
@Api(tags = "NavController")
@RestController
@RequestMapping("/nav")
public class NavController {

    @Autowired
    INavService navService;

    /**
     * 获取导航
     *
     * @return
     */
    @ApiOperation(value = "根据用户获取导航")
    @GetMapping("/getNavs")
    public Result getNavs(HttpServletRequest request) {
        return navService.getNas(request);
    }

    /**
     * 切换身份
     * @return
     */
    @ApiOperation(value = "切换身份")
    @PostMapping("/getNavById")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "身份类型", paramType = "query", dataTypeClass = String.class, required = true),
    })
    public Result getNavById(HttpServletRequest request, Integer type) {
        return navService.getNavById(request, type);
    }
}